package com.tz.colawallet.ui.presenter;

import com.tz.colawallet.basecode.base.BaseBiz;
import com.tz.colawallet.basecode.base.BaseRespNew;
import com.tz.colawallet.bean.GetTags;
import com.tz.colawallet.ui.biz.PerfectMessageBiz;
import com.tz.colawallet.ui.contract.PerfectMessageContract;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by Administrator on 2017/10/25.
 */

public class PerfectMessagePresenter implements PerfectMessageContract.PerfectMessagePresenter {

    PerfectMessageContract.View view;
    PerfectMessageBiz biz;

    @Inject
    public PerfectMessagePresenter(PerfectMessageContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        this.biz = (PerfectMessageBiz) biz;
    }

    @Override
    public void getTags() {
        view.loading(true);
        biz.getTags(view.curContext(), new BaseBiz.Callback<BaseRespNew<List<GetTags>>>() {
            @Override
            public void onSuccess(BaseRespNew<List<GetTags>> o) {
                view.showTags(o.getData());
                view.loading(false);
            }

            @Override
            public void onFailure(BaseRespNew o) {
                view.showMsg(o.getMsg());
                view.loading(false);
            }
        });
    }


    @Override
    public void detail(String username, int sex, String birth, String loanMoney, String tagids, String city) {
        view.loading(true);
        biz.detail(view.curContext(), username, sex, birth, loanMoney, tagids, city, new BaseBiz.Callback<BaseRespNew>() {
            @Override
            public void onSuccess(BaseRespNew o) {
                view.showDetail();
                view.loading(false);
            }

            @Override
            public void onFailure(BaseRespNew o) {
                view.showMsg(o.getMsg());
                view.loading(false);
            }
        });
    }


}
